﻿#include "Travel.h"

#include <osg/Geode>
#include <osg/ShapeDrawable>
#include <osg/Geometry>

osg::ref_ptr<osg::Geode> createSphere(const osg::Vec3d& center)
{
	osg::ref_ptr<osg::Geode> gnode = new osg::Geode;
	gnode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(center, 0.1)));
	return gnode;
}

int main()
{
	osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
	osg::ref_ptr<NodeMatrix> nm = new NodeMatrix;
	osg::ref_ptr<osg::Group> gp = new osg::Group;
	osg::ref_ptr<NodeMatrix> characater = new NodeMatrix();
	osg::ref_ptr<osg::Node> sphere = createSphere(osg::Vec3d(0.0, 0.0, 0.0));
	osg::ref_ptr<TravelManipulator> tm = new TravelManipulator;
	
	characater->addsChild(sphere.get());

	nm->addsChild(osgDB::readNodeFile("ceep.ive"));
	nm->toPosition(osg::Vec3d(0.0, 0.0, 0.0));
	
	gp->addChild(nm.get());
	gp->addChild(characater.get());

	tm->setCurrentNode(characater.get());
	tm->setNode(nm.get());

	viewer->setSceneData(gp.get());
	viewer->setCameraManipulator(tm);

	viewer->setUpViewInWindow(100, 100, 1024, 768);
	return viewer->run();
}